FROM php:7.1.5-fpm-alpine as php-base
COPY src /src
RUN     cd /src \
     && chmod +x php_extent.sh \
     && ./php_extent.sh

FROM nginx:1.21.0-alpine as nginx-base
COPY src /src
RUN     cd /src \
     && chmod +x nginx_extent.sh \
     && ./nginx_extent.sh

#多阶段编译打包

FROM ubuntu:18.04
ENV TZ=Asia/Shanghai \
    DEBIAN_FRONTEND=noninteractive \
    LC_ALL=zh_CN.UTF-8
WORKDIR /
COPY --from=php-base /php-7.1.5.tar.gz /
COPY --from=nginx-base /nginx-1.21.0.tar.gz /
COPY src/sources.list /etc/apt/sources.list
RUN     cd / \
     && apt update \
     && apt -y upgrade \
     && apt install -y tzdata locales \
     && locale-gen zh_CN.UTF-8 \
     && update-locale LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 \
     && ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \
     && echo ${TZ} > /etc/timezone \
     && dpkg-reconfigure --frontend noninteractive tzdata \
     && apt install -y curl \
     && tar -xvf php-7.1.5.tar.gz -C / --strip-components 1 \
     && tar -xvf nginx-1.21.0.tar.gz -C / --strip-components 1 \
     && rm php-7.1.5.tar.gz \
     && rm nginx-1.21.0.tar.gz \
     && rm -rf /var/lib/apt/lists/* \
     && groupadd work -g 501 \
     && useradd work -u 501 -g 501  -s /sbin/nologin